import {contextPath} from "../api";
import Mock from 'mockjs'
import qs from 'qs'
import {authority} from './authority'
import {businessHours,weiXinConfig} from './setting'
import {user,weiXinAuthStatus,bindSuccuss,bindError,userInfo,checkCode,checkRegister} from './user'
import {subscribeItem,subscribeList,subscribeStatus,holidayPartyItem,holidayPartyList,depositAbout,depositTerm,cancelSubscribeStatus} from "./subscribe";
import {roomTypeList,regionList,choosenTable} from './tableManager'
import {noticeIdList,noticeList,noticeItem,callList,callStatus,callServiceList,complainList} from './notice&callManager'
import {keepList,keepDetail,personKeepList,withDrawStatus} from './wineManager'
import {cardCount,payCodeValue,cardList,cardDetail} from './cardManager'

// 通过axios与后台交互，使用mock.js来拦截axios造假数据
if(contextPath.indexOf('https') <= 0 && contextPath == ''){//判断是否为开发调试环境
  Mock.mock(/weiXinAuth/,function(options) {
    //console.log('weiXinAuth的axios传值为：',qs.parse(options.body))//数据请求的传值
    return Mock.mock(weiXinAuthStatus)
  })

  Mock.mock(/getJsSignature/,function(options) {
    //console.log('getWeiXinConfig的axios传值为：',qs.parse(options.body))//数据请求的传值
    return Mock.mock(weiXinConfig)
  })

  Mock.mock(/bindPhone/,function(options) {
    //console.log('bindPhone的axios传值为：',qs.parse(options.body))//数据请求的传值
    let obj = qs.parse(options.body)
    if(obj.PHONE == user.phone){
      return Mock.mock(bindSuccuss)
    }else{
      return bindError
    }
  })

  Mock.mock(/getUserInfo/,function(options) {
    //console.log('getUserInfo的axios传值为：',qs.parse(options.body))//数据请求的传值
    if(qs.parse(options.body).USER_ID != '' && qs.parse(options.body).USER_ID != undefined)
      return Mock.mock(userInfo)
  })

  Mock.mock(/sendCheckCode/,function(options) {
    //console.log('sendCheckCode的axios传值为：',qs.parse(options.body))//数据请求的传值
    return Mock.mock(checkCode)
  })

  Mock.mock(/getNoticeIdList/,function(options) {
    //console.log('getNoticeIdList的axios传值为：',qs.parse(options.body))//数据请求的传值
    return Mock.mock(noticeIdList)
  })

  Mock.mock(/getNoticeByIds/,function(options) {
    //console.log('getNoticeByIds的axios传值为：',qs.parse(options.body))//数据请求的传值
    return Mock.mock(noticeList)
  })

  Mock.mock(/getNoticeDetail/,function(options) {
    //console.log('getNoticeDetail的axios传值为：',qs.parse(options.body))//数据请求的传值
    return Mock.mock(noticeItem)
  })

  Mock.mock(/changePassword/,function(options) {
    //console.log('changePassword的axios传值为：',qs.parse(options.body))//数据请求的传值
    return Mock.mock(thePassword)
  })

  Mock.mock(/getAuthority/,function(options) {
    //console.log('getAuthority的axios传值为：',qs.parse(options.body))//数据请求的传值
    if(qs.parse(options.body).USER_ID != '' && qs.parse(options.body).USER_ID != undefined)
      return Mock.mock(authority)
  })

  Mock.mock(/getBusinessHours/,function(options) {
    //console.log('getBusinessHours的axios传值为：',qs.parse(options.body))//数据请求的传值
    return Mock.mock(businessHours)
  })

  Mock.mock(/getSubscribeList/,function(options) {
    //console.log('getSubscribeList的axios传值为：',qs.parse(options.body))//数据请求的传值
    return Mock.mock(subscribeList)
  })

  Mock.mock(/getRoomType/,function(options) {
    //console.log('getRoomType的axios传值为：',qs.parse(options.body))//数据请求的传值
    return Mock.mock(roomTypeList)
  })

  Mock.mock(/checkRegistered/,function(options) {
    //console.log('checkRegistered的axios传值为：',qs.parse(options.body))//数据请求的传值
    return Mock.mock(checkRegister)
  })

  Mock.mock(/submitSubscribe/,function(options) {
    //console.log('submitSubscribe的axios传值为：',qs.parse(options.body))//数据请求的传值
    return Mock.mock(subscribeStatus)
  })

  Mock.mock(/getHolidayPartyById/,function(options) {
    //console.log('getHolidayPartyById的axios传值为：',qs.parse(options.body))//数据请求的传值
    return Mock.mock(holidayPartyItem)
  })

  Mock.mock(/getHolidayPartyList/,function(options) {
    //console.log('getHolidayPartyList的axios传值为：',qs.parse(options.body))//数据请求的传值
    return Mock.mock(holidayPartyList)
  })

  Mock.mock(/getSubscribeById/,function(options) {
    //console.log('getSubscribeById的axios传值为：',qs.parse(options.body))//数据请求的传值
    return Mock.mock(subscribeItem)
  })

  Mock.mock(/getDepositAbout/,function(options) {
    //console.log('getDepositAbout的axios传值为：',qs.parse(options.body))//数据请求的传值
    return Mock.mock(depositAbout)
  })

  Mock.mock(/getDepositTerm/,function(options) {
    //console.log('getDepositTerm的axios传值为：',qs.parse(options.body))//数据请求的传值
    return Mock.mock(depositTerm)
  })

  Mock.mock(/cancelSubscribe/,function(options) {
    //console.log('cancelSubscribe的axios传值为：',qs.parse(options.body))//数据请求的传值
    return Mock.mock(cancelSubscribeStatus)
  })

  Mock.mock(/getKeepList/,function(options) {
    //console.log('getKeepList的axios传值为：',qs.parse(options.body))//数据请求的传值
    return Mock.mock(keepList)
  })

  Mock.mock(/getKeepDetail/,function(options) {
    //console.log('getKeepDetail的axios传值为：',qs.parse(options.body))//数据请求的传值
    return Mock.mock(keepDetail)
  })

  Mock.mock(/getChoosenTable/,function(options) {
    //console.log('getChoosenTable的axios传值为：',qs.parse(options.body))//数据请求的传值
    return Mock.mock(choosenTable)
  })

  Mock.mock(/getPersonKeepList/,function(options) {
    //console.log('getPersonKeepList的axios传值为：',qs.parse(options.body))//数据请求的传值
    return Mock.mock(personKeepList)
  })

  Mock.mock(/withDrawKeepWine/,function(options) {
    //console.log('withDrawKeepWine的axios传值为：',qs.parse(options.body))//数据请求的传值
    return Mock.mock(withDrawStatus)
  })

  Mock.mock(/getCallList/,function(options) {
    //console.log('getCallList的axios传值为：',qs.parse(options.body))//数据请求的传值
    return Mock.mock(callList)
  })

  Mock.mock(/callAgain/,function(options) {
    //console.log('callAgain的axios传值为：',qs.parse(options.body))//数据请求的传值
    return Mock.mock(callStatus)
  })

  Mock.mock(/getLowerType/,function(options) {
    //console.log('getLowerType的axios传值为：',qs.parse(options.body))//数据请求的传值
    if(qs.parse(options.body).CALLSERVICETYPE_ID == 2)return Mock.mock(callServiceList)
    else if(qs.parse(options.body).CALLSERVICETYPE_ID == 3)return Mock.mock(complainList)
  })

  Mock.mock(/submitCallService/,function(options) {
    //console.log('submitCallService的axios传值为：',qs.parse(options.body))//数据请求的传值
    return Mock.mock(callStatus)
  })

  Mock.mock(/getCardCount/,function(options) {
    //console.log('getCardCount的axios传值为：',qs.parse(options.body))//数据请求的传值
    return Mock.mock(cardCount)
  })

  Mock.mock(/getPayCodeValue/,function(options) {
    //console.log('getPayCodeValue的axios传值为：',qs.parse(options.body))//数据请求的传值
    return Mock.mock(payCodeValue)
  })

  Mock.mock(/getCardList/,function(options) {
    //console.log('getCardList的axios传值为：',qs.parse(options.body))//数据请求的传值
    return Mock.mock(cardList)
  })

  Mock.mock(/getCardDetail/,function(options) {
    //console.log('getCardDetail的axios传值为：',qs.parse(options.body))//数据请求的传值
    return Mock.mock(cardDetail)
  })
}
